#include <stdbool.h>
#include <stddef.h>
 struct TreeNode {
     int val;
     struct TreeNode *left;
     struct TreeNode *right;
 };


bool isUnivalTree(struct TreeNode* root){
    if(root==NULL) return true;
    if(root->left!=NULL&&root->left->val!=root->val) return false;  
    //当左子节点不为空且值不等 返回false 右子节点同理
    if(root->right!=NULL&&root->right->val!=root->val) return false;

    //递归左节点和右节点分别判断
    return isUnivalTree(root->left)&&isUnivalTree(root->right);
}